package com.matt.repository;

import com.matt.domain.Leads;
import com.matt.domain.LeadsUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2018/6/13
 * *******************************
 */
public interface LeadsUserRepository extends JpaRepository<LeadsUser, String>,JpaSpecificationExecutor<LeadsUser>{


    Leads findByMobile(String mobile);

    LeadsUser findTopByChildBigNameAndMobileAndAreaIdAndDeletedFalse(String childBigName, String mobile, String areaId);

    List<LeadsUser> findByLeadsId(String id);

    LeadsUser findByLeadsIdAndMobile(String id, String mobile);

    @Query("SELECT l FROM LeadsUser l WHERE l.leadsId = ?1 AND l.type = 1")
    LeadsUser findBytLeadsIdAndType(String leadsId);

    List<LeadsUser> findByLeadsIdOrderByTypeAsc(String id);
}
